<template>
	<!-- D:/project/app/ydz-app-uniapp/static/images/login -->
	<view class="pagebody" :style="{ minheight: maxHeight }">
		<view class="topbgbox">
			<view class="justify-between align-center">
				<image @click="backpage" src="@/static/images/login/leftjt.png" alt=""
					style="width: 48rpx;height: 48rpx;"></image>
			</view>
			<view class="color303b39 fwbold" style="font-size: 60rpx;margin-top: 64rpx;margin-left: 23rpx;">
				{{type=='forget'?'密码重置':'设置密码'}}
			</view>
			<view class="color303b39 fz32" style="margin-top: 32rpx;margin-left: 23rpx;">
				欢迎来到药队长!
			</view>
			<view class="inputbox" style="margin-top: 100rpx;">
				<uni-easyinput type="password" v-model="password" :placeholderStyle="placeholderStyle"
					:placeholder="type=='forget'?'请输入您的新密码':'请输入您的密码'"></uni-easyinput>
			</view>
			<view class="inputbox" style="margin-top: 48rpx;">
				<uni-easyinput type="password" v-model="confirmpassword" :placeholderStyle="placeholderStyle"
					:placeholder="type=='forget'?'请确认您的新密码':'请确认您的密码'"></uni-easyinput>
			</view>
			<view class="align-center loginbtn justify-between">
				<button class="button fwbold" :style="{opacity:password.length>0?'1':'0.5'}"
					:disabled="password.length>0?false:true" type="primary" @click="submit">确认</button>
			</view>
		</view>
		<u-toast ref="uToast" />



	</view>
</template>

<script>
	import {
		register,
		retrievePwd
	} from '@/api/login.js'
	import store from "@/store"
	export default {
		onLoad(option) {
			// 获得屏幕最大高度
			let systemInfo = uni.getSystemInfoSync();
			this.maxHeight = systemInfo.windowHeight + "px";
			console.log('设置密码', option)
			this.type = option.type
		},
		data() {
			return {
				type: '',
				maxHeight: '',
				password: '',
				confirmpassword: '',
				placeholderStyle: "color:#7E8987;font-size:32rpx",
			}
		},
		mounted() {
			console.log(store.state.other.phone)
		},
		methods: {
			submit() {
				if (this.password == this.confirmpassword) {
					console.log(this.type == "register")
					if (this.type == "register") {
						let data = {
							"code": "",
							"confirmPassword": this.confirmpassword,
							"password": this.password,
							"username":store.state.other.phone,
							"uuid": "",
							"uuTags": "01",
						}
						register(data).then(res=>{
							
						})
					} else if(this.type == "forget"){
						let data = {
							'phonenumber':store.state.other.phone,
							'password':this.password
						}
						retrievePwd(data).then(res=>{
							
						})
					}
					this.$refs.uToast.show({
						title: '密码设置成功请登陆',
						type: 'success',
						url: '/pages/login/otherlogin'
					})
					setTimeout(()=>{
						uni.navigateTo({
						    url:'/pages/login/otherlogin'
						});
					},2000)


				} else {
					this.$refs.uToast.show({
						title: '输入两次密码不一致',
					})
				}

			},
			backpage() {
				uni.navigateBack({
					delta: 1
				});
			}
		}
	};
</script>

<style lang="scss" scoped>
	page {
		background: #fff;
	}

	::v-deep .is-input-border {
		border: none;
	}

	::v-deep .uni-easyinput__content {
		background: transparent !important;
	}

	::v-deep .uni-input-input {
		font-size: 32rpx;
	}

	::v-deep uni-checkbox .uni-checkbox-input {
		background: transparent;
	}

	::v-deep uni-checkbox .uni-checkbox-input.uni-checkbox-input-checked {
		color: #fff;
		border-color: #00D9B2;
		background: #00D9B2;
	}

	::v-deep .uni-icons {
		font-size: 52rpx !important;
	}

	::v-deep uni-toast {
		font-size: 24rpx;
	}

	.pagebody {
		box-sizing: border-box;
		background-image: url('/static/images/login/otherbg.png');
		position: relative;
		background-repeat: no-repeat;
		background-size: cover;

		.topbgbox {
			// position: relative;
			// height: 9.2100rpx;
			box-sizing: border-box;
			padding: 14rpx 40rpx 0;


			.inputbox {
				border-bottom: 1rpx solid #B8C3C1;
				padding-bottom: 10rpx;
			}

			.loginbtn {
				// position: absolute;
				// bottom: 0;
				margin-top: 96rpx;

				uni-button {
					border-radius: 98rpx;
					width: 668rpx;
				}

				uni-button:after {
					border: none;
				}

				.button {
					background-color: #00D9B2;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 36rpx;

				}
			}
		}

	}
</style>